/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


package uta.valloytoalloy;

import edu.mit.csail.sdg.alloy4whole.*;

//RMV
import java.io.*;

/**
 * ValloyInputController: Use this class to pass all the
 * inputs from a GUI Interface, or any commands other
 * input commands to the ValloyConverter.  You will then call the ValloyParser
 * to implement the business logic of the Parser.
 * You may think of this as an input tester.  At the end we may only need
 * one simple command execution.
 * @author vasr
 */
public class ValloyInputController {

    SimpleGUI asguiParent;
    
    public ValloyInputController()
    {
    
    }
    
    public ValloyInputController(SimpleGUI pParent)
    {
        asguiParent = pParent;
    }
    
    
    //TODO:
    //RV NOtes: Replace with code that
    //1- Extracts the Class Hierarchy and put it into a file, or a
    //JTextArea.  I need to figure out how it can be sent directly
    //to an alloy window and the format we may need.  For now we need the business
    //logic to the parsing.
    static public  void ExtractClassHierarchy(javax.swing.JTextArea AlloyTextArea)
    {
       try{
            // Open the file that is the first
            // command line parameter
            String _FileName = "C:\\UT Classes\\Source Code\\ValloyAlloyConverter\\Data\\FunctionData.txt";
            File openAs = new File(_FileName);
            FileReader in = new FileReader(openAs);
            AlloyTextArea.read(in, openAs.toString());
        }
        catch(java.io.IOException ex){
                System.out.println("Cannot read from file");
        }
    }

    //TODO:
    //RV NOtes: Replace with code that
    //1- Extracts the Generate Alloy Functions and put it into a file, or a
    //JTextArea.  I need to figure out how it can be sent directly
    //to an alloy window and the format we may need.  For now we need the business
    //logic to the parsing.
    static public  void GenerateAlloyFunctions(javax.swing.JTextArea AlloyTextArea)
    {
       try{
            // Open the file that is the first
            // command line parameter
            String _FileName = "C:\\UT Classes\\Source Code\\ValloyAlloyConverter\\Data\\FunctionData.txt";
            File openAs = new File(_FileName);
            FileReader in = new FileReader(openAs);
            AlloyTextArea.read(in, openAs.toString());
        }
        catch(java.io.IOException ex){
                System.out.println("Cannot read from file");
        }
    }

    //TODO:
    //RV NOtes: Replace with code that
    //1- Displayed a Windows to select a File.
    //This may be done with code from Alloy
    static  public  void OpenValloyFile(javax.swing.JTextArea ValloyTextArea,
            SimpleGUI pParent )
    {
                
        if(pParent != null)
        {
            try{
            File filename = pParent.doValloyOpen(ValloyTextArea);
            if( filename != null )
            {
            FileReader inin = new FileReader(filename);
                ValloyTextArea.read(inin, filename.toString());
            }
            }
            catch(java.io.IOException ex){
                    System.out.println("Cannot read from file");
            }
            
       
        }
        else
        {
            try{
                // Open the file that is the first
                // command line parameter
                String _FileName = "C:\\UT Classes\\Source Code\\ValloyAlloyConverter\\Data\\ValloyData.txt";
                File openAs = new File(_FileName);
                FileReader in = new FileReader(openAs);
                ValloyTextArea.read(in, openAs.toString());
            }
            catch(java.io.IOException ex){
                    System.out.println("Cannot read from file");
            }
        }
    }
    //TODO
    //RMV: Form here we transfered the alloy convertion and we tranfer it
    //directly to Alloy so it can be run.  One of the easy way to do this
    //is by writting the conversion into a temp file, passing the file name to alloy
    //and opening the file automatically.
    //
    //NOTE:  After we have the business login of conversion we can then very easilly
    //skip this manual step and after conversion we execute this process.
    static public void ExportToAlloy()
    {

    }

    //TODO
    //RMV: A command indicating tha Valloy is being close
    static public void ExitValloy()
    {

    }
    
}

    //Please add the input commands relevant to }
